#include<stdio.h>
#include<stdlib.h>
#include <errno.h>

#include <arpa/inet.h> 
#include <netinet/in.h>

#include <sys/mman.h>
#include <fcntl.h>
#include <sys/stat.h>
#include "structures.h"
//#include "Liste/ListeClients.h"

/*


SOCKADDR_IN* neighbour(SOCKADDR_IN *csin) {

  // renvoie la structure utilisable pour tous les membres du reseau  
  if (csin == NULL) {
    perror("POinteur nul");
    return NULL;
  }
  
  return csin;
}

*/


/*void initialisation(identifiant id, ) {*/



//void propagation(varaiable *csin) {

  /*rajouter un tableau dune structure variable 
    pour chaque membre du reseau */


//  int i = 0;
  /*int b;
  for (b = 0 ; b < max ; b++) {
    printf("%d\t", table[b]->port);
  }
  */
  /*while ((table[i]->port > 0) && (i < max))  {
    printf("OK\n");
    if (( table[i]->port == csin->port )&& (table[i]->ip.s_addr = csin->ip.s_addr)) {
      printf("client deja connu\n");
      exit(0);
    }
    i++;
  }
  */
/*
  FILE* fd;

  if ((fd = fopen("neighbour.txt","a+")) != NULL) {

  fprintf(fd, "client n°: %d ip : %u\t port: %d\n", 0, csin->ip.s_addr, csin->port);

  }
  else perror("fopen");
  fclose(fd);
}*/


void neighbourhood() {

  int i = 0;
  FILE* fd;
  fd = fopen("neighbour.txt","w+");
  while (i < max) {
    if (table[i]->ip.s_addr != 0) 
      fprintf(fd, "client n°: %d ip : %u\t port: %d\n", i, table[i]->ip.s_addr, table[i]->port);
    i++;
  }
  
}


